package com.kuang.swagger.controller;

import com.kuang.swagger.pojo.User;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    // /error 已经写好的请求

    @GetMapping("/hello")
    public String hello(){
        return "Hello,Swagger";
    }

    //只要这个实体在请求接口的返回值上(即使是泛型) 都能映射到实体项中!
    @GetMapping("/user")
    public User user1(){
        return new User();
    }

    @ApiOperation("返回name的方法")
    @PostMapping("/name")
    public String getName(@ApiParam("这个名字会被返回") String name){
        return name;
    }
}
